/**
 * @param {number} n
 * @param {number} delay
 * @param {number} forget
 * @return {number}
 */
var peopleAwareOfSecret = function(n, delay, forget) {
  let arr = new Array(forget + 1).fill(0);

  function computeCanSay() {
    let sum = 0;
    for(let i = delay; i < forget; i++) {
      sum += arr[i];
    }
    return sum;
  }
  function moveToNext() {
    for(let i = forget; i >= 1; i--) {
      arr[i] = arr[i - 1];
    }
  }

  for(let i = 0; i < n; i++) {
    if(i == 0) {
      arr[0] = 1;
    } else {
      moveToNext();
      let init = computeCanSay();
      arr[0] = init;
      if(arr[0] > 1000000000 + 7) {
        arr[0] %= (1000000000 + 7);
      }
    }
  }
  let result = 0;
  for(let i = 0; i < forget; i++) {
    result += arr[i];
    if(result > 1000000000 + 7) {
      result %= (1000000000 + 7);
    }
  }
  return result;
};
let n = 6, delay = 2, forget = 4;
console.log(peopleAwareOfSecret(n, delay, forget));
n = 4, delay = 1, forget = 3;
console.log(peopleAwareOfSecret(n, delay, forget));
n = 684, delay = 18, forget = 496;
console.log(peopleAwareOfSecret(n, delay, forget));
